package abs.service;

import abs.domain.Companias;
import abs.domain.Sucursales;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/absWeb-security-context.xml",
		"file:./resources/absWeb-service-context.xml",
		"file:./resources/absWeb-dao-context.xml",
		"file:./resources/absWeb-web-context.xml" })
@Transactional
public class SucursalesServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected SucursalesService service;

	/**
	 * Instantiates a new SucursalesServiceTest.
	 *
	 */
	public SucursalesServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findSucursalesByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findSucursalesByPrimaryKey 
		String co001cdgo = null;
		Sucursales response = null;
		response = service.findSucursalesByPrimaryKey(co001cdgo);
		// TODO: JUnit - Add assertions to test outputs of operation: findSucursalesByPrimaryKey
	}

	/**
	 * Operation Unit Test
	 * Return all Sucursales entity
	 * 
	 */
	@Test
	public void findAllSucursaless() {
		// TODO: JUnit - Populate test inputs for operation: findAllSucursaless 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<Sucursales> response = null;
		response = service.findAllSucursaless(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllSucursaless
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Sucursales entity
	 * 
	 */
	@Test
	public void deleteSucursales() {
		// TODO: JUnit - Populate test inputs for operation: deleteSucursales 
		Sucursales sucursales = new abs.domain.Sucursales();
		service.deleteSucursales(sucursales);
	}

	/**
	 * Operation Unit Test
	 * Return a count of all Sucursales entity
	 * 
	 */
	@Test
	public void countSucursaless() {
		Integer response = null;
		response = service.countSucursaless();
		// TODO: JUnit - Add assertions to test outputs of operation: countSucursaless
	}

	/**
	 * Operation Unit Test
	 * Load an existing Sucursales entity
	 * 
	 */
	@Test
	public void loadSucursaless() {
		Set<Sucursales> response = null;
		response = service.loadSucursaless();
		// TODO: JUnit - Add assertions to test outputs of operation: loadSucursaless
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Companias entity
	 * 
	 */
	@Test
	public void deleteSucursalesCompanias() {
		// TODO: JUnit - Populate test inputs for operation: deleteSucursalesCompanias 
		String sucursales_co001cdgo = null;
		String related_companias_co000nocia = null;
		Sucursales response = null;
		response = service.deleteSucursalesCompanias(sucursales_co001cdgo, related_companias_co000nocia);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteSucursalesCompanias
	}

	/**
	 * Operation Unit Test
	 * Save an existing Sucursales entity
	 * 
	 */
	@Test
	public void saveSucursales() {
		// TODO: JUnit - Populate test inputs for operation: saveSucursales 
		Sucursales sucursales_1 = new abs.domain.Sucursales();
		service.saveSucursales(sucursales_1);
	}

	/**
	 * Operation Unit Test
	 * Save an existing Companias entity
	 * 
	 */
	@Test
	public void saveSucursalesCompanias() {
		// TODO: JUnit - Populate test inputs for operation: saveSucursalesCompanias 
		String co001cdgo_1 = null;
		Companias related_companias = new abs.domain.Companias();
		Sucursales response = null;
		response = service.saveSucursalesCompanias(co001cdgo_1, related_companias);
		// TODO: JUnit - Add assertions to test outputs of operation: saveSucursalesCompanias
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
